package com.jule.miaozhuapc.webSocket;

import com.jule.miaozhuapc.webSocket.control.WawaControlWebSocket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.handler.TextWebSocketHandler;
@Configuration
@EnableWebMvc
@EnableWebSocket
public class webSocketConfig   extends WebMvcConfigurerAdapter implements WebSocketConfigurer {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

	@Override
	public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
		// TODO Auto-generated method stub
		// registry.addHandler("/play/control")
		registry.addHandler(webSocketHandler(), "/wawa/control");
		registry.addHandler(new WawaControlWebSocket(), "/wawa/roomUse");
		//.addInterceptors(new SpringWebSocketHandlerInterceptor())
	}

	@Bean
	public TextWebSocketHandler webSocketHandler() {
		return new WawaControlWebSocket();
	}
}
